package com.mti.flexmusicplayer.filesearch
{
import com.mti.flexmusicplayer.model.MusicModel;

import flash.events.Event;
import flash.filesystem.File;
import flash.media.Sound;
import flash.net.URLRequest;

import mx.collections.IList;

public final class FileSearchEvent extends Event
{
	public var fileFound:File;
	
	
	public function FileSearchEvent(read:File, other:mx.collections.IList):void
	{
		var music:MusicModel = new MusicModel(new Sound(new URLRequest(read.nativePath)), read.name);
		music.sound.addEventListener(Event.COMPLETE, onSoundLoaded);
		
		function onSoundLoaded(evt:Event):void
		{
			other.addItem(music);
		}
		
		super("FileSearchEvent");	
	}
	
	override public function clone():Event
	{
		return super.clone();	
	}
	
}
}